import Vue from 'vue'
import Vuex from 'vuex'
import http from '../util/http/axios'

Vue.use(Vuex)
Vue.use(http)

const store = new Vuex.Store({
  state: {
    baseColor: '#ee3f4d',
    userInfo: {}
  },
  mutations: {
    UPDATE_USER_INFO(state) {
      http.get('/users/user-info', {
        name: JSON.parse(sessionStorage.getItem('tokenInfo')).name
      }).then(
        res => {
          if (res.code === 200) {
            console.log('res')
            sessionStorage.setItem('userInfo', JSON.stringify(res.data))
            state.userInfo = res.data
            console.log(state.userInfo)
          }
        }
      )
    }
  }
})

export default store
